lib: Change ot_util_variant_map helpers to consistently sink refs
authorColin Walters <walters@verbum.org>
Wed, 1 Jun 2016 13:35:47 +0000 (09:35 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 1 Jun 2016 15:02:41 +0000 (15:02 +0000)
This is similar to changes Krzesimir has been doing recently - we
really don't need the ergonomics of floating refs since we have
autocleanups.

We should continue to change most of our code to sink refs.

Specifically here it was pretty broken that the `_map()` API was
sinking but the other two weren't, and this broke some refactoring I
was trying to do later.

Closes: #317
Approved by: jlebon

src/libostree/ostree-repo-static-delta-core.c
src/libotutil/ot-variant-utils.c

index 9e3ed09f65e79934751bd879ed543209b2c68137..013837128450ec79955ed315b4e6498e2f0c2bed 100644 (file)
@@ -512,6 +512,7 @@ _ostree_static_delta_part_open (GInputStream   *part_in,
                                                                     g_bytes_get_size (inline_part_bytes) - 1);
           ret_part = g_variant_new_from_bytes (G_VARIANT_TYPE (OSTREE_STATIC_DELTA_PART_PAYLOAD_FORMAT_V0),
                                                content_bytes, trusted);
+          g_variant_ref_sink (ret_part);
         }
 
       if (!skip_checksum)
index 7b54542ee7ac1756400e9e1ac5d6696ad2ee259d..b9fe94b94d54dd3ecc2e4a8ae8f9a51ef84822fd 100644 (file)
@@ -166,7 +166,6 @@ ot_util_variant_map_at (int dfd,
                         GError  **error)
 {
   glnx_fd_close int fd = -1;
-  g_autoptr(GVariant) ret_variant = NULL;
 
   fd = openat (dfd, path, O_RDONLY | O_CLOEXEC);
   if (fd < 0)
@@ -224,8 +223,8 @@ ot_util_variant_map_fd (int                    fd,
   mdata->len = len;
 
   ret = TRUE;
-  *out_variant = g_variant_new_from_data (type, map, len, trusted,
-                                          variant_map_data_destroy, mdata);
+  *out_variant = g_variant_ref_sink (g_variant_new_from_data (type, map, len, trusted,
+                                                              variant_map_data_destroy, mdata));
  out:
   return ret;
 }